/*********************************************************************
 * Software License Agreement
 *
 * Copyright (C) 2010 Cross The Road Electronics.  All rights
 * reserved.
 *
 * Cross The Road Electronics (CTRE) licenses to you the right to 
 * use, copy, modify, merge, publish, distribute, sublicense, and/or 
 * sell copies of the Software ONLY when in use with CTRE's 2CAN 
 * Ethernet CAN Gateway.
 *
 * THE SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT
 * WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT
 * LIMITATION, ANY WARRANTY OF MERCHANTABILITY, FITNESS FOR A
 * PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
 * CROSS THE ROAD ELECTRONICS BE LIABLE FOR ANY INCIDENTAL, SPECIAL, 
 * INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF
 * PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
 * BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE
 * THEREOF), ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION, OR OTHER
 * SIMILAR COSTS, WHETHER ASSERTED ON THE BASIS OF CONTRACT, TORT
 * (INCLUDING NEGLIGENCE), BREACH OF WARRANTY, OR OTHERWISE.
 *
********************************************************************/
#ifndef _2CANClientDefs__h_
#define _2CANClientDefs__h_

#include "../Common/Os Abstraction/stdint.h"

enum
{
	OUTPUT_ENABLE_JAG1,
	OUTPUT_ENABLE_JAG2,
	OUTPUT_ENABLE_JAG3,
	OUTPUT_ENABLE_JAG4,
	OUTPUT_ENABLE_JAG5,
	OUTPUT_ENABLE_JAG6,
	OUTPUT_ENABLE_JAG7,
	OUTPUT_ENABLE_JAG8,
	OUTPUT_ENABLE_JAG9,
	OUTPUT_ENABLE_JAG10,
	OUTPUT_ENABLE_JAG11,
	OUTPUT_ENABLE_JAG12,
	OUTPUT_ENABLE_JAG13,
	OUTPUT_ENABL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ELAY4

typedef enum _EnableState
{
	Disabled,
	Teleop,
	Auton,
}EnableState;

typedef struct _CommStats
{
	uint32_t rxCount;
	uint32_t txCount;
	uint32_t rxTimeFromLastMs;

#define CommStatsNoResponse	(1ul)

	uint32_t statusFlags;
	uint32_t txCountFailed;
	uint32_t reserved[8];
}CommStats;

typedef struct _Found2Can
{
	uint8_t ip[6];

	#define Found2Can_Status_InBootloader	(1)
	#define Found2Can_Status_InApplication	(2)
	uint16_t iStatusBits;
	
	uint16_t iFirmwareMajor;
	uint16_t iFirmwareMinor;
	
	uint16_t iBootloaderMajor;
	uint16_t iBootloaderMinor;
	
	uint16_t iManDay;
	uint16_t iManMonth;
	uint16_t iManYear;
	
	uint16_t iHardwareRevMajor;
	uint16_t iHardwareRevMinor;
	
	uint16_t reserved[4];
}Found2Can;
#endif // _2CANClient__h_

